﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AppManagement.Models;

namespace AppManagement.Reports
{
    public partial class FrmPrintVeXe : Form
    {
        private Ve ObjVe;

        public FrmPrintVeXe(Ve _ve)
        {
            InitializeComponent();
            this.ObjVe = _ve;
            LoadData();
        }

        public void LoadData()
        {
            rptInVe rpt = new rptInVe();
            rpt.DataDefinition.FormulaFields["TuyenDuong"].Text = "'" + 
                this.ObjVe.ChiTietLichHoatDong.LichHoatDong.ChuyenXe.TuyenXe.DiaDiem.TenDiaDiem + " - " + 
                this.ObjVe.ChiTietLichHoatDong.LichHoatDong.ChuyenXe.TuyenXe.DiaDiem1.TenDiaDiem + "'";
            rpt.DataDefinition.FormulaFields["SoGhe"].Text = "'" + this.ObjVe.SoGhe + "'";
            rpt.DataDefinition.FormulaFields["SoXe"].Text = "'" + this.ObjVe.ChiTietLichHoatDong.LichHoatDong.ChuyenXe.Xe.MaBSXe + "'";
            rpt.DataDefinition.FormulaFields["GioXuatBen"].Text = "'" + this.ObjVe.ChiTietLichHoatDong.LichHoatDong.ChuyenXe.GioKhoiHanh + "'";
            rpt.DataDefinition.FormulaFields["NgayXuatBen"].Text = "'" + String.Format("{0:dd/MM/yyyy}", this.ObjVe.ChiTietLichHoatDong.NgayHoatDong) + "'";
            rpt.DataDefinition.FormulaFields["GiaCuoc"].Text = "'" + String.Format("{0:#,##0;Nothing}", this.ObjVe.ChiTietLichHoatDong.LichHoatDong.ChuyenXe.DonGia) + " đ'";
            rpt.DataDefinition.FormulaFields["NgayThangNam"].Text = "'Ngày " + DateTime.Now.Day.ToString() + " tháng " + DateTime.Now.Month.ToString() + " năm " + DateTime.Now.Year.ToString() + "'";
            crystalReportViewer1.ReportSource = rpt;
        }
    }
}
